/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */

bool IsSame(struct TreeNode* root, struct TreeNode* subRoot){
    if(!root && !subRoot)
        return true;
    else if(!root ^ !subRoot)
        return false;
    return (IsSame(root->left, subRoot->left) && IsSame(root->right, subRoot->right) && root->val == subRoot->val);
}

bool isSubtree(struct TreeNode* root, struct TreeNode* subRoot){
    if(!root && !subRoot)
        return true;
    else if(!root)
        return false;
    else if(!subRoot)
        return true;
    else if(root->val == subRoot->val && IsSame(root, subRoot))
        return true;
    return (isSubtree(root->left, subRoot) || isSubtree(root->right, subRoot));
}